package no.sachmuld.methodcombination.examples.annotation.aopstyle.foo;


import no.sachmuld.aspectjattach.AspectJAgent;

/**
 *
 */
public class Main implements Runnable {

    @Override
    public void run() {

        AspectJAgent.initializeIfNeeded();

        new Runnable() {

            @Override
            public void run() {

                {
                    Foo fooX = new FooX();
                    System.out.println(fooX.bar(1));
                    System.out.println(fooX.baz(2));

                    Foo fooY = new FooY();
                    System.out.println(fooY.bar(3));
                    System.out.println(fooY.baz(4));
                }

                {
                    Foo fooX = new FooX().with(new TransactionalBehaviour(), new LoggingBehaviour());
                    System.out.println(fooX.bar(1));
                    System.out.println(fooX.baz(2));

                    Foo fooY = new FooY().with(new TransactionalBehaviour(), new LoggingBehaviour());
                    System.out.println(fooY.bar(3));
                    System.out.println(fooY.baz(4));
                }

                {
                    Foo fooX = new FooX().with(new TransactionalBehaviour());
                    fooX.bar(1);
                    fooX.chain().push(new LoggingBehaviour());
                    fooX.bar(2);
                    fooX.chain().pop();
                    fooX.bar(3);
                }


            }

        }.run();

    }

    public static void main(String... args) throws Exception {
        new Main().run();
    }

}
